import java.util.Arrays;
import java.util.Scanner;

public class test2 {

    import java.util.*;
    public class Main {
        public  void main(String args[]) {
            Scanner sc = new Scanner(System.in);
            int n = sc.nextInt();
            int coins[] = new int[n];
            for(int i = 0;i < n;i++)
                coins[i] = sc.nextInt();
            int amount = sc.nextInt();
            Solution s = new Solution();
            System.out.println(s.coinChange(coins, amount));
        }
    }
    class Solution {
        public int coinChange(int[] coins, int amount) {
            int dp[] =new int[amount+1];
            Arrays.fill(dp, amount+1);
            dp[0] = 0;
            for(int i = 0;i < dp.length;i++)
            {
                for(int coin:coins)
                {
                    if(i - coin < 0)
                        continue;
                    dp[i] = Math.min(dp[i], dp[i - coin]+1);
                }
            }
            return dp[amount] == amount+1?-1:dp[amount];
        }
    }




        public void main(String args[]) {
            Scanner sc = new Scanner(System.in);
            int n = sc.nextInt();
            int coins[] = new int[n];
            for(int i = 0;i < n;i++)
                coins[i] = sc.nextInt();
            int amount = sc.nextInt();
            Solution s = new Solution();
            System.out.println(s.coinChange(coins, amount));
        }


        int memo[];
        public int coinChange(int[]coins, int amount)
        {
            memo = new int[amount+1];
            Arrays.fill(memo, -666);
            return coin(coins, amount);
        }

        public int coin(int[] coins, int amount) {
            if(amount == 0)
                return 0;
            if(amount < 0)
                return -1;//退出条件
            if(memo[amount] != -666)
                return memo[amount];
            int res = Integer.MAX_VALUE;
            for(int coin : coins)
            {
                int number = coin(coins, amount - coin);
                if(number == -1)
                    continue;
                res = Math.min(res, number + 1);
            }
            memo[amount] = (res== Integer.MAX_VALUE)?-1:res;
            return memo[amount];
        }


        import java.util.Scanner;
    public class T3 {

        public static void main(String[] args) {
            // TODO Auto-generated method stub
            Scanner sc=new Scanner(System.in);

            System.out.println("请输入总人数");
            int n=sc.nextInt();

            System.out.println("请输入从编号为"+"的人开始报数");
            int k=sc.nextInt();

            System.out.println("请输入出队的人的序号");
            int m=sc.nextInt();


            int []arr=new int[n];
            int x=n;//剩余的人数
            int j=0;//第一个开始报数的人
            while(x>1) {
                if(k==n)
                    k=0;//限制范围
                if(arr[k]==0) {
                    j++;
                    if(j==m) {//当到达m个人时，令该位置数组的值等于1
                        arr[k]=1;
                        x--;
                        j=0;
                    }
                }
                k++;
            }
            for(int a=0;a<n;a++) {
                if(arr[a]==0) {
                    System.out.println(a);
                    break;
                }

            }
        }

    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int T = sc.nextInt();
        sc.nextLine();
        long totalByte = 0;
        for (int i = 0; i < T; i++) {//处理T条赋值语句,求总byte数
            totalByte += handle(sc.nextLine());
        }
        System.out.println(change(totalByte));
    }

    private static long handle(String statement) {
        if (statement.isEmpty()) return 0;
        int type = getType(statement);//方便判断类型
        if (type == 1 || type == 2) {//数组
            int cnt = 0;//数组长度之和
            String[] res = statement.split("[=,]");//按照"="和","切割,这样奇数项就是"new type[len]"的形式
            for (int j = 1; j < res.length; j += 2) {
                //截取每个数组长度c
                int idx1 = res[j].lastIndexOf("["), idx2 = res[j].lastIndexOf("]");
                int c = Integer.parseInt(res[j].substring(idx1 + 1, idx2));
                cnt += c;
            }
            return type == 1 ? cnt * 4L : cnt * 8L;
        }
        if (type == 5) {
            String[] res = statement.split("\"");
            long len = 0;//统计长度
            for (int j = 1; j < res.length; j += 2) {
                len += res[j].length();
            }
            return len;
        }
        int count = 0;//赋值语句个数
        for (char ch : statement.toCharArray()) {
            if (ch == '=') count++;
        }
        return type == 3 ? count * 4L : count * 8L;
    }

    private static int getType(String statement) {
        if (statement.startsWith("int[]")) return 1;
        if (statement.startsWith("long[]")) return 2;
        if (statement.startsWith("int")) return 3;//注意需要先处理数组
        if (statement.startsWith("long")) return 4;
        return 5;//String
    }

    /**
     将字节转换为aGBbMBcKBd形式的字符串
     */
    private static String change(long totalByte) {
        StringBuilder res = new StringBuilder();
        String[] units = new String[]{"B", "KB", "MB", "GB"};
        //1024进制
        for (int i = 0; i < 4 && totalByte > 0; i++) {//单位只有4个,循环4次
            int t = (int) (totalByte % 1024);
            if (t != 0) res.insert(0, t + units[i]);//如果该位为0则不输出数字和单位
            totalByte /= 1024;
        }
        return res.toString();
    }




}
